package com.yellowpage.client.service;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;
import com.yellowpage.client.data.NspUserAccount;
import com.yellowpage.client.dao.NspUserAccountDao;

public class NspUserAccountServiceImpl extends BaseServiceImpl implements NspUserAccountService {
	  private NspUserAccountDao nspUserAccountDao;
	
	  public void setNspUserAccountDao(NspUserAccountDao nspUserAccountDao) {
		  this.nspUserAccountDao = nspUserAccountDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public NspUserAccount getNspUserAccount(Long id){
	      return nspUserAccountDao.get(id);
	  }
	  

	  
    public List<NspUserAccount> getAllNspUserAccount(){
        return nspUserAccountDao.getAll();
    }
    
    public List<Map> queryNspUserAccountByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.MOBILENO , a.REGISTTIME , a.ACCOUNTTYPE , a.ACCOUNTUSER , a.SUBMITTER , a.SUBMITTIME , a.UPDATEUSER , a.UPDATETIME , a.ID , a.DESCRIPTION , a.PASSWORD    FROM NSP_USER_ACCOUNT a WHERE 1=1 ")
				    			.addCondition(" and MOBILENO = :mobileNo ")
							    			.addCondition(" and date_format(REGISTTIME,'%Y-%m-%d') = :registTime ")
							    			.addCondition(" and ACCOUNTTYPE = :accountType ")
							    			.addCondition(" and ACCOUNTUSER = :accountUser ")
							    			.addCondition(" and SUBMITTER = :submitter ")
							    			.addCondition(" and date_format(SUBMITTIME,'%Y-%m-%d') = :submitTime ")
							    			.addCondition(" and UPDATEUSER = :updateUser ")
							    			.addCondition(" and date_format(UPDATETIME,'%Y-%m-%d') = :updateTime ")
							    			.addCondition(" and ID = :id ")
							    			.addCondition(" and DESCRIPTION = :description ")
							    			.addCondition(" and PASSWORD = :password ")
							    ; 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveNspUserAccount(NspUserAccount nspUserAccount){
        nspUserAccountDao.save(nspUserAccount);
    }
    
    
	  public void updateNspUserAccount(NspUserAccount nspUserAccount){
	      nspUserAccountDao.update(nspUserAccount);
	  }
	  
	  
	  
	  
	  
	  public void delete(List deleteList){
	      nspUserAccountDao.remove(deleteList);
	  }
	  
	  
	 
	
}	